#ifndef _VISUALIZATION_GRAPH_H_
#define _VISUALIZATION_GRAPH_H_

#include "Global.h"
//#include "google/sparse_hash_map"
//#include <hash_map>
#include <queue>
#include "SequenceGraph.h"
#include <fstream>
#include <string>
//using stdext::hash_compare;
//using namespace stdext;

class SequenceGraphViz
{
private:
	//hash_map<GID_T,int> m_Visited;
	unsigned char* m_visited;
	SequenceGraph * m_seqGraph;
	const string& m_OutputDir;
	queue<GID_T> m_Queue;
	int m_components;
	int m_largestComponentSize;
	int m_totalComponentSize;

	/**
	 * 	writeData as if it is a undirected graph, but only out edges are outputed.
	 *
	 * @author	Tao Yu
	 * @date	2011/3/23
	 *
	 * @param	FilePath	Full pathname of the file.
	 * @return Estimated valid number of bases.
	 */
	int InternalBFS(GID_T id, ofstream& nodeStream, ofstream& edgeStream);
	//void CreateAdjAndData();
	inline bool isVisited(GID_T id) { return (m_visited[id >> 3] >> (id % 8)) & 1; }
	inline void setVisited(GID_T id) {  m_visited[id >> 3] |= (1 << (id % 8)); }
	void writeVertex(SequenceVertex * v, ofstream& nodeStream);
	void writeEdge(GID_T onode, GID_T inode, GINT32 multiplicity, ofstream& edgeStream);
public:
	SequenceGraphViz(SequenceGraph *seqGraph, const string& fileName);
	~SequenceGraphViz(void);
	void writeData();
	int numOfComponents() { return m_components; }
	int largestComponentSize() { return m_largestComponentSize; }
	int totalComponentSize() { return m_totalComponentSize; }
};

#endif